package com.satan.novel.home.manager.feign;

import com.satan.novel.book.dto.resp.BookInfoRespDto;
import com.satan.novel.book.feign.BookFeign;
import com.satan.novel.common.resp.RestResp;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Demon
 * @Date: 2024/1/21 19:56
 * @Description: 小说微服务调用 Feign 客户端管理
 **/
@Component
@RequiredArgsConstructor
public class BookFeignManager {
    private final BookFeign bookFeign;

    public List<BookInfoRespDto> listBookInfoByIds(List<Long> bookIds) {
        RestResp<List<BookInfoRespDto>> resp = bookFeign.listBookInfoByIds(bookIds);
        if (resp.isOk()) {
            return resp.getData();
        }
        return new ArrayList<>(0);
    }

}
